<template>
	<view class="">
		<view class="auditStatus" v-if="userData.status == 0">
			<view class="f40 fb primary">
				工匠入驻审核中...
			</view>
			<image class="rzsh" src="https://img.aibbyp.com/wechatUser/category1/rzsh.png" mode=""></image>
			<view class="tss">
				温馨提示：提交平台审核，平台在3个工作日内会以电话回访方式进行人工审核
			</view>
			<view class="flex btns">
				<view class="sxzt" @click="getAuth">刷新状态</view>
				<view class="qxrz ml24" @click="fhxg">返回修改</view>
			</view>
		</view>
		<view class="auditStatus" v-if="userData.status == 1">
			<view class="f40 fb primary">
				工匠入驻成功
			</view>
			<image class="rzsh" src="https://img.aibbyp.com/wechatUser/category1/rzsh.png" mode=""></image>
			<view class="tss">
				温馨提示：您可使用我的页面中的工匠专属服务
			</view>
			<view class="flex btns">
				<view class="sxzt" @click="getAuth">刷新状态</view>
				<view class="qxrz ml24" @click="fhxg">返回修改</view>
			</view>
		</view>
		<view class="auditStatus" v-if="userData.status == 2">
			<view class="f40 fb error">
				工匠入驻失败！
			</view>
			<image class="rzsh" src="https://img.aibbyp.com/wechatUser/category1/rzsb.png" mode=""></image>
			<view class="tss tss1">
				温馨提示：请联系客服了解未通过原因，返回修改相关信息后再次上传审核。
			</view>
			<view class="flex btns">
				<view class="sxzt" @click="qxrz">取消入驻</view>
				<view class="qxrz ml24" @click="fhxg">返回修改</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userData: {
					status: 0
				}
			}
		},
		onLoad() {
			this.getAuth()
		},
		methods: {
			qxrz() {
				uni.reLaunch({
					url: '/pages/tabbarcompotant/my/user'
				})
			},
			fhxg() {
				uni.reLaunch({
					url: '/pages/craftsman/guide?type=delete'
				})
			},
			getrefresh() {
				this.$api.post({
					url: '/wanlshop/user/refresh',
					success: res => {
						uni.setStorageSync("wanlshop:user", res.userinfo);
						this.$store.dispatch('user/login', res);
						this.$store.dispatch('cart/login');
						this.$store.commit('statistics/edit', res.statistics);
						this.$store.commit('user/setUserInfo', res.userinfo);
						this.$forceUpdate()
					}
				});
			},

			getAuth() {
				this.$api.post({
					url: '/worker/user/getAuth',
				}).then(res => {
					console.log(res);
					this.userData = res
					if (res.status == 1) {
						this.getrefresh()
						uni.showModal({
							title: '审核通过',
							content: '您可使用我的页面中的工匠专属服务',
							success: function(res) {
								if (res.confirm) {
									uni.reLaunch({
										url: '/pages/tabbarcompotant/index/landlord'
									})
								}
							}
						})
					}
					//状态:status0=待审核,1=审核通过,2=审核未通过
				})
			},

		},
	}
</script>

<style scoped>
	.auditStatus {
		padding: 150rpx 32rpx 0;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.rzsh {
		width: 362rpx;
		height: 362rpx;
		margin-top: 40rpx;

	}

	.tss {
		font-size: 24rpx;
		color: #4C96EC;
		padding: 20rpx;
		background: #FAFDFF;
		margin-top: 100rpx;
		border-radius: 20rpx;
	}

	.tss1 {
		color: #FD5241;
		background: #FFF2F0;
	}

	.sxzt {
		padding: 18rpx 62rpx;
		font-size: 40rpx;
		color: #FD5241;
		font-weight: bold;
		border: 2rpx solid #FD5241;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.qxrz {
		background: #FD5241;
		color: #fff;
		font-weight: bold;
		font-size: 40rpx;
		padding: 18rpx 62rpx;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.btns {
		position: fixed;
		bottom: 30rpx;
		padding-bottom: env(safe-area-inset-bottom);
	}
</style>